import 'main/main_find_page.dart';
import 'main/main_home_page.dart';
import 'main/main_my_page.dart';
import 'package:flutter/material.dart';
import 'main/main_forum_page.dart';

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  List<String> tabTitleList = ["首页", "论坛", "发现", "我的"];
  List<String> normalIconUrl = ["home.png", "forum.png", "found.png", "my.png"];
  List<String> selectedIconUrl = [
    "home_1.png",
    "forum_1.png",
    "found_1.png",
    "my_1.png"
  ];
  List<Widget> pageList = [
    // 首页
    MainHomePage(),
    // 论坛
    MainForumPage(),
    // 发现
    MainFindPage(),
    // 我的
    MainMyPage()
  ];
  // 当前选中
  num selectIndex = 0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: pageList[selectIndex],
      bottomNavigationBar: BottomNavigationBar(
        // 是否显示 label
        // showUnselectedLabels: true,
        unselectedItemColor: Colors.grey,
        selectedItemColor: Color(0xFF43CCF8),
        currentIndex: selectIndex,
        onTap: (value) {
          setState(() {
            selectIndex = value;
          });
        },
        items: <BottomNavigationBarItem>[
          BottomNavigationBarItem(
              icon: Image.asset(
                "images/2.0/${normalIconUrl[0]}",
                width: 18,
                height: 18,
              ),
              activeIcon: Image.asset(
                "images/2.0/${selectedIconUrl[0]}",
                width: 18,
                height: 18,
              ),
              label: tabTitleList[0]),
          BottomNavigationBarItem(
              icon: Image.asset(
                "images/2.0/${normalIconUrl[1]}",
                width: 18,
                height: 18,
              ),
              activeIcon: Image.asset(
                "images/2.0/${selectedIconUrl[1]}",
                width: 18,
                height: 18,
              ),
              label: tabTitleList[1]),
          BottomNavigationBarItem(
              icon: Image.asset(
                "images/2.0/${normalIconUrl[2]}",
                width: 18,
                height: 18,
              ),
              activeIcon: Image.asset(
                "images/2.0/${selectedIconUrl[2]}",
                width: 18,
                height: 18,
              ),
              label: tabTitleList[2]),
          BottomNavigationBarItem(
              icon: Image.asset(
                "images/2.0/${normalIconUrl[3]}",
                width: 18,
                height: 18,
              ),
              activeIcon: Image.asset(
                "images/2.0/${selectedIconUrl[3]}",
                width: 18,
                height: 18,
              ),
              label: tabTitleList[3]),
        ],
      ),
    );
  }
}
